/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package models;

import javax.persistence.Entity;
import play.data.validation.Email;
import play.data.validation.Required;
import play.db.jpa.Model;

/**
 *
 * @author alexwong
 */
@Entity
public class Usuario extends Model {
    
    @Email
    @Required
    public String email;
    
    @Required
    public String password;
    
    public String nombre;
    
    public static Usuario connect(String email, String password) {
        return find("byEmailAndPassword", email, password).first();
    }
    
    public static Usuario obtenerUsuario(String email) {
        return find("byEmail", email).first();
    }
    
    @Override
    public String toString() {
        return nombre;
    }
        
}
